package IC.Types;

public class ArrayType extends Type {
	
	private final Type InnerType;

	//C'tor
	public ArrayType(Type InnerType) {
		this.InnerType = InnerType;
	}
	
	public Type getInnerType() {
		return InnerType;
	}
	
	@Override
	public boolean isSuitForArray() {
		return true;
	}

	@Override
	public boolean isArray() {
		return true;
	}

	@Override
	public boolean isClass() {
		return false;
	}

	@Override
	public boolean isMethod() {
		return false;
	}

	@Override
	public boolean isPrimitive() {
		return false;
	}
	
	@Override
	public String toString() {
		return getInnerType()+"[]";
	}
	
	/**
	 * trims the array sign off an arrayType id.
	 */
	public static String trimArraySign(String id) {
		int index = id.indexOf('[');
		return (index == -1) ? id : id.substring(0, index);
	}
	
}
